home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Employee_M2065065112007.psc / Employee Manager / frmdeletion.frm < prev    next >
Text File  |  2007-05-10  |  12KB  |  374 lines

  1. VERSION 5.00
  2. Begin VB.Form frmdeletion 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00000000&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Employee Deletion Manager"
  7.    ClientHeight    =   3555
  8.    ClientLeft      =   3780
  9.    ClientTop       =   2400
  10.    ClientWidth     =   4860
  11.    ControlBox      =   0   'False
  12.    BeginProperty Font 
  13.       Name            =   "Tahoma"
  14.       Size            =   8.25
  15.       Charset         =   238
  16.       Weight          =   700
  17.       Underline       =   0   'False
  18.       Italic          =   0   'False
  19.       Strikethrough   =   0   'False
  20.    EndProperty
  21.    KeyPreview      =   -1  'True
  22.    LinkTopic       =   "Form1"
  23.    LockControls    =   -1  'True
  24.    MaxButton       =   0   'False
  25.    MinButton       =   0   'False
  26.    ScaleHeight     =   3555
  27.    ScaleWidth      =   4860
  28.    Begin VB.CommandButton cmdremove 
  29.       Caption         =   "Remove"
  30.       Height          =   255
  31.       Left            =   2850
  32.       TabIndex        =   11
  33.       Top             =   3210
  34.       Width           =   930
  35.    End
  36.    Begin VB.CommandButton cmdclose 
  37.       Caption         =   "Cancel"
  38.       Height          =   255
  39.       Left            =   3840
  40.       TabIndex        =   10
  41.       Top             =   3210
  42.       Width           =   930
  43.    End
  44.    Begin VB.TextBox txtaddress 
  45.       Appearance      =   0  'Flat
  46.       Enabled         =   0   'False
  47.       Height          =   285
  48.       Left            =   1725
  49.       TabIndex        =   9
  50.       Top             =   2175
  51.       Width           =   3030
  52.    End
  53.    Begin VB.TextBox txtname 
  54.       Appearance      =   0  'Flat
  55.       Enabled         =   0   'False
  56.       Height          =   285
  57.       Left            =   1725
  58.       TabIndex        =   8
  59.       Top             =   1845
  60.       Width           =   3030
  61.    End
  62.    Begin VB.TextBox txtsalary 
  63.       Appearance      =   0  'Flat
  64.       Enabled         =   0   'False
  65.       Height          =   285
  66.       Left            =   1725
  67.       TabIndex        =   7
  68.       Top             =   2835
  69.       Width           =   1710
  70.    End
  71.    Begin VB.TextBox txtphone 
  72.       Appearance      =   0  'Flat
  73.       Enabled         =   0   'False
  74.       Height          =   285
  75.       Left            =   1725
  76.       TabIndex        =   6
  77.       Top             =   2505
  78.       Width           =   1710
  79.    End
  80.    Begin VB.TextBox txtempid 
  81.       Appearance      =   0  'Flat
  82.       BackColor       =   &H00FFFFFF&
  83.       Enabled         =   0   'False
  84.       Height          =   285
  85.       Left            =   1725
  86.       TabIndex        =   5
  87.       Top             =   1515
  88.       Width           =   1215
  89.    End
  90.    Begin VB.Frame Frame1 
  91.       BackColor       =   &H00FF0000&
  92.       BorderStyle     =   0  'None
  93.       Height          =   225
  94.       Left            =   30
  95.       TabIndex        =   3
  96.       Top             =   30
  97.       Width           =   4800
  98.       Begin VB.Label lblmsg 
  99.          Alignment       =   2  'Center
  100.          AutoSize        =   -1  'True
  101.          BackStyle       =   0  'Transparent
  102.          Caption         =   "Welcome to Employee Deletion Manager"
  103.          ForeColor       =   &H00FFFFFF&
  104.          Height          =   195
  105.          Left            =   720
  106.          TabIndex        =   4
  107.          Top             =   0
  108.          Width           =   3420
  109.       End
  110.    End
  111.    Begin VB.ComboBox cboempid 
  112.       BeginProperty Font 
  113.          Name            =   "Tahoma"
  114.          Size            =   6.75
  115.          Charset         =   238
  116.          Weight          =   700
  117.          Underline       =   0   'False
  118.          Italic          =   0   'False
  119.          Strikethrough   =   0   'False
  120.       EndProperty
  121.       Height          =   285
  122.       Left            =   1260
  123.       Style           =   2  'Dropdown List
  124.       TabIndex        =   2
  125.       Top             =   795
  126.       Width           =   2430
  127.    End
  128.    Begin VB.Frame Frame2 
  129.       BackColor       =   &H00FF0000&
  130.       BorderStyle     =   0  'None
  131.       Height          =   225
  132.       Left            =   30
  133.       TabIndex        =   0
  134.       Top             =   1215
  135.       Width           =   4800
  136.       Begin VB.Label lblemp 
  137.          Alignment       =   2  'Center
  138.          AutoSize        =   -1  'True
  139.          BackStyle       =   0  'Transparent
  140.          Caption         =   "Details of Employee to be Removed"
  141.          ForeColor       =   &H00FFFFFF&
  142.          Height          =   195
  143.          Left            =   930
  144.          TabIndex        =   1
  145.          Top             =   0
  146.          Width           =   3000
  147.       End
  148.    End
  149.    Begin VB.Shape Shape1 
  150.       BorderColor     =   &H00FF8080&
  151.       BorderWidth     =   2
  152.       Height          =   3540
  153.       Left            =   15
  154.       Top             =   15
  155.       Width           =   4845
  156.    End
  157.    Begin VB.Label Label5 
  158.       AutoSize        =   -1  'True
  159.       BackStyle       =   0  'Transparent
  160.       Caption         =   "Basic Salary : "
  161.       ForeColor       =   &H0000FFFF&
  162.       Height          =   195
  163.       Left            =   195
  164.       TabIndex        =   17
  165.       Top             =   2895
  166.       Width           =   1155
  167.    End
  168.    Begin VB.Label Label4 
  169.       AutoSize        =   -1  'True
  170.       BackStyle       =   0  'Transparent
  171.       Caption         =   "Phone No : "
  172.       ForeColor       =   &H0000FFFF&
  173.       Height          =   195
  174.       Left            =   195
  175.       TabIndex        =   16
  176.       Top             =   2580
  177.       Width           =   915
  178.    End
  179.    Begin VB.Label Label3 
  180.       AutoSize        =   -1  'True
  181.       BackStyle       =   0  'Transparent
  182.       Caption         =   "Address : "
  183.       ForeColor       =   &H0000FFFF&
  184.       Height          =   195
  185.       Left            =   195
  186.       TabIndex        =   15
  187.       Top             =   2250
  188.       Width           =   825
  189.    End
  190.    Begin VB.Label Label2 
  191.       AutoSize        =   -1  'True
  192.       BackStyle       =   0  'Transparent
  193.       Caption         =   "Name : "
  194.       ForeColor       =   &H0000FFFF&
  195.       Height          =   195
  196.       Left            =   195
  197.       TabIndex        =   14
  198.       Top             =   1920
  199.       Width           =   615
  200.    End
  201.    Begin VB.Label Label1 
  202.       AutoSize        =   -1  'True
  203.       BackStyle       =   0  'Transparent
  204.       Caption         =   "Employee ID : "
  205.       ForeColor       =   &H0000FFFF&
  206.       Height          =   195
  207.       Left            =   195
  208.       TabIndex        =   13
  209.       Top             =   1590
  210.       Width           =   1200
  211.    End
  212.    Begin VB.Label Label6 
  213.       BackStyle       =   0  'Transparent
  214.       Caption         =   "Select Employee ID from the list to be deleted or select all from remove popup menu :"
  215.       ForeColor       =   &H0000FFFF&
  216.       Height          =   480
  217.       Left            =   390
  218.       TabIndex        =   12
  219.       Top             =   300
  220.       Width           =   3915
  221.    End
  222.    Begin VB.Menu mnuremove 
  223.       Caption         =   "Remove"
  224.       Visible         =   0   'False
  225.       Begin VB.Menu mnusel 
  226.          Caption         =   "Selected"
  227.       End
  228.       Begin VB.Menu mnuall 
  229.          Caption         =   "All"
  230.       End
  231.    End
  232. End
  233. Attribute VB_Name = "frmdeletion"
  234. Attribute VB_GlobalNameSpace = False
  235. Attribute VB_Creatable = False
  236. Attribute VB_PredeclaredId = True
  237. Attribute VB_Exposed = False
  238. Option Explicit
  239.  
  240. Private Sub cboempid_Click()
  241. If cboempid.ListIndex > 0 Then
  242.     Set rs = db.OpenRecordset("select *from info where empno='" & cboempid.Text & "'")
  243.     If rs.RecordCount > 0 Then
  244.         lblemp.Caption = "Details of Employee " & cboempid.Text & " to be Removed"
  245.         txtempid.Text = rs("empno")
  246.         txtname.Text = rs("name")
  247.         txtaddress.Text = rs("address")
  248.         txtphone.Text = rs("phone")
  249.         txtsalary.Text = rs("salary")
  250.         txtempid.BackColor = vbWhite
  251.         txtname.BackColor = vbWhite
  252.         txtaddress.BackColor = vbWhite
  253.         txtphone.BackColor = vbWhite
  254.         txtsalary.BackColor = vbWhite
  255.     End If
  256.     Set rs = Nothing
  257. Else
  258.     Exit Sub
  259. End If
  260. End Sub
  261.  
  262. Private Sub cmdclose_Click()
  263. confirm = MsgBox("Are you sure to exit ?", vbApplicationModal + vbYesNo + vbQuestion, "Exit Deletion")
  264. If confirm = vbNo Then
  265.     cboempid.SetFocus
  266.     Exit Sub
  267. ElseIf confirm = vbYes Then
  268.     Unload Me
  269.     frmmenu.optadd.SetFocus
  270. End If
  271. End Sub
  272.  
  273. Private Sub cmdremove_Click()
  274. If Trim(txtempid.Text) <> "" Then
  275.     mnusel.Enabled = True
  276. Else
  277.     mnusel.Enabled = False
  278. End If
  279. If cboempid.ListCount > 1 Then
  280.     mnuall.Enabled = True
  281. ElseIf cboempid.ListCount = 1 Then
  282.     mnuall.Enabled = False
  283. End If
  284. PopupMenu mnuremove
  285. End Sub
  286.  
  287. Private Sub Form_Load()
  288. Left = (Screen.Width - Me.Width) / 2
  289. Top = (Screen.Height - Me.Height) / 2
  290.  
  291. Set db = OpenDatabase(App.Path & "\employee.mdb")
  292. Set rs = db.OpenRecordset("info", dbOpenTable)
  293. If rs.RecordCount > 0 Then rs.MoveFirst
  294.  
  295. cboempid.AddItem "-=Select Emp ID=-"
  296. Do Until rs.EOF
  297.     cboempid.AddItem rs("empno")
  298.     rs.MoveNext
  299. Loop
  300. cboempid.ListIndex = 0
  301. txtempid.BackColor = &HC0C0C0
  302. txtname.BackColor = &HC0C0C0
  303. txtaddress.BackColor = &HC0C0C0
  304. txtphone.BackColor = &HC0C0C0
  305. txtsalary.BackColor = &HC0C0C0
  306. End Sub
  307.  
  308. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  309. If KeyCode = vbKeyEscape Then cmdclose_Click
  310. End Sub
  311.  
  312. Private Sub mnuall_Click()
  313. confirm = MsgBox("Are you sure to truncate the employee record table ?", vbApplicationModal + vbYesNo + vbQuestion, _
  314.             "Confirm Removal")
  315. If confirm = vbNo Then
  316.     cboempid.SetFocus
  317.     Exit Sub
  318. ElseIf confirm = vbYes Then
  319.     frmdelprogress.Show vbModal
  320. End If
  321. End Sub
  322.  
  323. Private Sub mnusel_Click()
  324. confirm = MsgBox("Are you sure to remove record of Employee " & txtempid.Text & " from the database ?", vbApplicationModal + vbYesNo + vbQuestion, _
  325.             "Confirm Removal")
  326. If confirm = vbNo Then
  327.     txtempid.Text = ""
  328.     txtaddress.Text = ""
  329.     txtname.Text = ""
  330.     txtphone.Text = ""
  331.     txtsalary.Text = ""
  332.     txtempid.BackColor = &HC0C0C0
  333.     txtname.BackColor = &HC0C0C0
  334.     txtaddress.BackColor = &HC0C0C0
  335.     txtphone.BackColor = &HC0C0C0
  336.     txtsalary.BackColor = &HC0C0C0
  337.     cboempid.ListIndex = 0
  338.     cboempid.SetFocus
  339. ElseIf confirm = vbYes Then
  340.     Set rs = db.OpenRecordset("select *from info where empno='" & txtempid.Text & "'")
  341.     If rs.RecordCount > 0 Then
  342.         rs.Delete
  343.     End If
  344.     txtempid.Text = ""
  345.     txtaddress.Text = ""
  346.     txtname.Text = ""
  347.     txtphone.Text = ""
  348.     txtsalary.Text = ""
  349.     txtempid.BackColor = &HC0C0C0
  350.     txtname.BackColor = &HC0C0C0
  351.     txtaddress.BackColor = &HC0C0C0
  352.     txtphone.BackColor = &HC0C0C0
  353.     txtsalary.BackColor = &HC0C0C0
  354.     MsgBox "Successfully removed employee record from the database.", vbApplicationModal + vbInformation, "Done"
  355.     Set rs = db.OpenRecordset("info", dbOpenTable)
  356.     If rs.RecordCount > 0 Then
  357.         rs.MoveFirst
  358.         cboempid.Clear
  359.         cboempid.AddItem "-=Select Emp ID=-"
  360.         Do Until rs.EOF
  361.             cboempid.AddItem rs("empno")
  362.             rs.MoveNext
  363.         Loop
  364.         cboempid.ListIndex = 0
  365.         cboempid.SetFocus
  366.     ElseIf rs.RecordCount = 0 Then
  367.         MsgBox "There is currently no employee record available for further removal." & vbCrLf & "Employee deletion manager will now close.", _
  368.             vbApplicationModal + vbInformation, "Empty Database"
  369.         Unload Me
  370.         frmmenu.optadd.SetFocus
  371.     End If
  372. End If
  373. End Sub
  374.